package com.jthinker.blog.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * User: Gang Chen
 * Date: 2015/6/14 21:59
 */
public interface BaseDao<M extends Serializable, PK extends Serializable>
{
    PK save(M model);

    void saveOrUpdate(M model);

    void update(M model);

    void merge(M model);

    void delete(PK id);

    void deleteObject(M model);

    M get(PK id);

    int countAll();

    List<M> listAll();

    List<M> listAll(int pn, int pageSize);

    List<M> pre(PK pk, int pn, int pageSize);

    List<M> next(PK pk, int pn, int pageSize);

    boolean exists(PK id);

    void flush();

    void clear();

    int count(String hql, Object... paramList);

    boolean isUnique(M entity, String... uniquePropertyNames);

    int count(String hql, Map<String, Object> params);

    <T> T read(String hql, Map<String, Object> params);

    <T> List<T> list(String hql);

    <T> List<T> list(String hql, int pn, int pageSize);

    <T> List<T> list(String hql, int pn, int pageSize, String sort, String sortOrder);

    <T> List<T> list(String hql, int pn, int pageSize, Map<String, Object> params);

    <T> List<T> list(String hql, int pn, int pageSize, String sort, String sortOrder, Map<String, Object> params);
}
